package com.example.yls.intent_service;

import android.app.Service;
import android.content.Intent;
import android.os.IBinder;
import android.util.Log;

public class MyService extends Service {
    public MyService() {
    }

    @Override
    public IBinder onBind(Intent intent) {
        // TODO: Return the communication channel to the service.
        throw new UnsupportedOperationException("Not yet implemented");
    }

    //到了29不会自动销毁
    @Override
    public void onCreate() {
        super.onCreate();
        Log.e("MyService","thread id="+Thread.currentThread().getId());

        int i = 0;
        while (i < 30) {
            Log.e("MyService", "i=" + i);
            i++;
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }

    @Override
    public void onDestroy() {
        Log.e("MyService","onDestroy");
        super.onDestroy();
    }
}
